/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import model.entities.Role;
import model.entities.RoleSV;
import model.entities.RoomStatus;

/**
 *
 * @author Hieu.Nguyen
 */
public class RoleSVDAO {
    private static RoleSVDAO roleSVDAO;

    public static RoleSVDAO getInstance() {
        if (roleSVDAO == null) {
            roleSVDAO = new RoleSVDAO();
        }
        return roleSVDAO;
    }
    private String roleSVName;
    
     public List<RoleSV> getRoleSV(boolean isActived) {
        List<RoleSV> listRoleSV = new ArrayList<RoleSV>();
        try {
            Connection conn = ConnectionFactory.getConnection();
            String sql = "select * from tblRoleSV";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                RoleSV r = new RoleSV();
                r.setRoleSVID(rs.getInt("RoleSVID"));
                r.setRoleSVName(rs.getString("RoleSVName"));
                r.setRoleSVDescription(rs.getString("RoleSVDescription"));
                listRoleSV.add(r);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return listRoleSV;
    }
      public RoleSV getRoleSVByID(int roleSVID) {

        RoleSV rt = new RoleSV();
        try {
            Connection conn = ConnectionFactory.getConnection();
            String sql = "select * from tblRoleSV where RoleSVID = ?";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            pstmt.setInt(1, roleSVID);
            
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                
                rt.setRoleSVID(rs.getInt("RoleSVID"));
                rt.setRoleSVName(rs.getString("RoleSVName"));
                rt.setRoleSVDescription(rs.getString("RoleSVDescription"));
             
                
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return rt;
     }

    public RoleSV getRoleSVByID(int idRoleSVName, boolean b) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
}
